package com.push.notifications;

import android.app.IntentService;
import android.content.Intent;
import android.os.Bundle;


public class DownloadService extends IntentService {
	public DownloadService() {
		super("Download Service1");
	}

	@Override
	protected void onHandleIntent(Intent intent) {
		Bundle receiveBundle = intent.getExtras();
		IDownloadedItem downloadItem = new DownloadedItem();
		downloadItem.setFileName(receiveBundle.getString("fileName"));
		downloadItem.setUrl(receiveBundle.getString("url"));
		downloadItem.setName(receiveBundle.getString("name"));
		if(DownloadThread.state==DownloadThread.ACTION_DOWNLOADING){	
			ServiceQueueDownloadUtil.pushDownloadTaskQueue(getApplicationContext(), downloadItem);
		} else {
			ServiceQueueDownloadUtil.pushDownloadTaskQueue(getApplicationContext(), downloadItem);
			ServiceQueueDownloadUtil.runDownloadQueue(getApplicationContext());
		}
	}
}
